const glob = require("glob");
const path = require("path");
const fs = require("fs");

const allFiles = glob.sync("*", {
  cwd: path.resolve(__dirname, "../polyfills/dist"),
  nodir: true,
});

async function collect() {
  const allContents = {};
  for (const i of allFiles) {
    allContents[i] = fs.readFileSync(
      path.resolve(__dirname, "../polyfills/dist/" + i),
      "utf-8"
    );
  }

  fs.writeFileSync(
    path.resolve(__dirname, "../src/polyfills.ts"),
    `export default ${JSON.stringify(allContents)}`
  );
}

collect();
